<button type="button" data-controller="dropdown" data-target="actions-proposal-<%= proposal.id %>" aria-label="<%= t("decidim.admin.actions.actions_label", resource: proposal.title) %>">
  <%= icon "more-fill", class: "text-secondary" %>
</button>

<div class="inline-block relative">
  <ul id="actions-proposal-<%= proposal.id %>" class="dropdown dropdown__action" aria-hidden="true">
    <% if view == :deleted %>
      <li class="dropdown__item">
        <%= link_to restore_proposal_path(proposal), method: :patch, class: "dropdown__button" do %>
          <%= icon "refresh-line" %>
          <%= t("actions.restore", scope: "decidim.admin") %>
        <% end %>
      </li>
    <% else %>
      <% if allowed_to? :edit, :proposal, proposal: proposal %>
        <li class="dropdown__item">
          <%= link_to edit_proposal_path(proposal), class: "dropdown__button" do %>
            <%= icon "pencil-line" %>
            <%= t("actions.edit_proposal", scope: "decidim.proposals") %>
          <% end %>
        </li>
      <% else %>
        <li class="dropdown__item">
          <div class="dropdown__button-disabled">
            <%= with_tooltip t("tooltips.cannot_edit_proposal_info", scope: "decidim.admin") do %>
              <%= icon "pencil-line", class: "text-gray" %>
              <span>
                <%= t("actions.edit_proposal", scope: "decidim.proposals") %>
              </span>
            <% end %>
          </div>
        </li>
      <% end %>

      <hr>

      <li class="dropdown__item">
        <%= link_to resource_locator(proposal).path, target: :blank, data: { "external-link": false }, class: "dropdown__button" do %>
          <%= icon "eye-line" %>
          <%= t("actions.preview", scope: "decidim.proposals.admin") %>
        <% end %>
      </li>

      <hr>

      <li class="dropdown__item">
        <% if allowed_to?(:create, :proposal_answer, proposal:) && !proposal.emendation? %>
          <%= link_to proposal_path(proposal), class: "dropdown__button" do %>
            <%= icon "question-answer-line" %>
            <%= t("actions.answer_proposal", scope: "decidim.proposals") %>
          <% end %>
        <% else %>
          <%= link_to proposal_path(proposal), class: "dropdown__button" do %>
            <%= icon "information-line" %>
            <%= t("actions.show", scope: "decidim.proposals") %>
          <% end %>
        <% end %>
      </li>

      <hr>

      <li class="dropdown__item">
        <%= dropdown_resource_permissions_link(proposal) %>
      </li>

      <hr>

      <li class="dropdown__item">
        <% if allowed_to?(:soft_delete, :proposal, trashable_deleted_resource: proposal) %>
          <%= link_to soft_delete_proposal_path(proposal), method: :patch, data: { confirm: t("actions.confirm_delete_proposal", scope: "decidim.proposals.admin") }, class: "dropdown__button" do %>
            <%= icon "delete-bin-line" %>
            <%= t("actions.soft_delete", scope: "decidim.admin") %>
          <% end %>
        <% else %>
          <div class="dropdown__button-disabled">
            <%= with_tooltip t("tooltips.deleted_proposals_info", scope: "decidim.admin") do %>
              <%= icon "pencil-line", class: "text-gray" %>
              <span>
                <%= t("actions.edit_proposal", scope: "decidim.proposals") %>
              </span>
            <% end %>
          </div>
        <% end %>
      </li>
    <% end %>
  </ul>
</div>
